Part Number Hot Search : 
ST211100 IPB05 VRE304JD A102J TB0296A TFS115D HA118002 NNS3012
Product Description
Full Text Search
 

To Download AN3980 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  november 2011 doc id 022200 rev 1 1/18 AN3980 application note stm32? firmware library for dspin l6470 1 introduction this application note describes the implementation of the stm32 firmware library for the dspin stepper motor control product (l6470). it provides a guide on how to use the library for final application development. the l6470 is a fully integrated microstepping motor driver with embedded motion engine and spi communication interface. a low r dson dmos power stage is also a part of the ic. the chip supports different operating modes including a 128-microstep resolution. it is based on digital control core surrounded with a number of different peripherals and protections. chip operating mode, motion profiles, and all the other parameters are memorized in an embedded set of registers. communication with the ic is done through an integrated 5 mhz spi periphery in determined data format according to the documentation. see the l6470 datasheet for more details about registers, application commands, etc. the firmware library speeds up the application development process and saves time consumed by register constant definitions and command routine implementation in the microcontroller source code. firmware library main features designed for the stm32f1xx microcontroller family steval-pcc009v2 + stm32 value line discovery demonstration boards supported with library configuration (dspin.h) and development tools project files easy portability due to ansi c standard compliance ? only hal (?hardware abstraction layer?) routines should be modified when used with another platform ? simple portability to stm8? families thanks to similar hal routines for peripherals - spi, gpios, etc. library contains project folders (files) for development tools: ? iar? - ewarm v5 j-link for steval-pcc009v2 st-link for stm32 vl discovery ? iar - ewarm v6 j-link for steval-pcc009v2 ? keil - vision ? v4.03, v4.20 ulink2 ? for steval-pcc009v2 ulink pro for steval-pcc009v2 st-link for stm32 vl discovery ? raisonance - ride v7 r-link for steval-pcc009v2 www.st.com
AN3980 contents doc id 022200 rev 1 2/18 contents 1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 library file structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 3 demonstration board electrical connection . . . . . . . . . . . . . . . . . . . . . . 6 4 dspin.h file content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4.1 demonstration board related signal assignments . . . . . . . . . . . . . . . . . . . 7 4.2 dspin init structure definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 4.3 register options / mask definition (enumerated types) . . . . . . . . . . . . . . . 9 4.4 l6470 register addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 4.5 l6470 command set definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 4.6 macros definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 5 dspin.c file content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 6 main.c file content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 appendix a demonstration board images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
list of figures AN3980 3/18 doc id 022200 rev 1 list of figures figure 1. firmware library folder structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 figure 2. firmware library file list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 figure 3. demonstration board selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 figure 4. demonstration board signal assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 figure 5. l6470 registers structure type definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 figure 6. step select parameter definition for ?step mode? register . . . . . . . . . . . . . . . . . . . . . . . . . . 9 figure 7. configuration register mask definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 figure 8. register addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 figure 9. l6470 command set type definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 figure 10. list of defined macros. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 figure 11. demonstration board steval-pcc009v2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 figure 12. demonstration board stm32f100 value line discovery kit . . . . . . . . . . . . . . . . . . . . . . . . 15 figure 13. l6470 demonstration board ( eval6470) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
AN3980 library file structure doc id 022200 rev 1 4/18 2 library file structure firmware implementation is split between the following files: dspin.c ? microcontroller peripherals initialization ? dspin application commands implementation ? library support functions implementation dspin.h ? function prototypes for implemented commands and support functions ? register value (options) definition ? register mask definition ? macros for selected function parameter conversions ? demonstration board related definitions - gpio signals and peripherals assignment main.c ? example of library usage - system configuration / function calls other microcontroller configuration files, such as ? clock.c, -.h, stm32f10x_conf.h (peripherals configuration), stm32f10x_it.c, -.h (interrupt routines) and standard library for gpio and spi firmware is available for download in compressed zip format. by decompressing the archive the following folder structure is created on a drive: figure 1. firmware library folder structure the ?libraries? folder contains microcontroller related files like peripheral source/header files, startup file, etc.
library file structure AN3980 5/18 doc id 022200 rev 1 the ?project? folder contains demonstration board related subfolders. dspin library source and header files and other subfolders with project files for different development tools appear in each of the demonstration board subfolders. a list of the source/header files can be seen in figure 2 : figure 2. firmware library file list
AN3980 demonstration board electrical connection doc id 022200 rev 1 6/18 3 demonstration board electrical connection the firmware library supports two demonstration boards: 1. steval-pcc009v2 universal usb to serial bus interface 2. stm32f100 value line discovery kit in the case of steval-pcc009v2, the connection of the l6470 demonstration board is simple. it is only necessary to use a 10-wire flat cable connection line inserted into j1 on steval-pcc009v2 and j10 on the l6470 demonstration board. the signals are assigned according to the appropriate section in the dspin.h file, see ta ble 1 : microcontroller peripherals for the stm32f100 value line discovery kit connection have been selected according to table 2 . the user is free to modify the assignment according to their needs. the condition for correct functionality is consistency between physical connection and dspin.h file content. table 1. microcontroller signal assignment for steval-pcc009v2 l6470 demonstration board signal microcontroller periphery spi clock pb 13 spi mosi pb 15 spi miso pb 14 spi nss pb 12 busy pb 10 flag pb 11 pwm 1 pb 0 pwm 2 pb 1 steval-pcc009v2 power led pc 4 table 2. microcontroller signal assignment for stm32f100 value line discovery kit l6470 demonstration board signal microcontroller periphery spi clock pa 5 spi mosi pa 7 spi miso pa 6 spi nss pa 4 busy pc 4 flag pc 5 pwm 1 pa 1 pwm 2 pb 0
dspin.h file content AN3980 7/18 doc id 022200 rev 1 4 dspin.h file content the dspin.h file contains the following: demonstration board related signal assignments structure definition for l6470 register initialization register options / mask definition (enumerated types) l6470 register addresses (enumerated types) l6470 command set definition (enumerated types) macro definition - used for function input parameter conversions list of function prototypes which are implemented in the dspin.c file. 4.1 demonstration board related signal assignments demonstration board type must be defined prior to the signal assignment definition. therefore, one of the following lines should appear at the beginning of the dspin.h file: figure 3. demonstration board selection it is recommended to keep both in the code and comment the one which does not correspond to the requested configuration.
AN3980 dspin.h file content doc id 022200 rev 1 8/18 in figure 4 it is possible to see how the signals are assigned depending on the demonstration board type: figure 4. demonstration board signal assignment the second demonstration board option, stm32 value line discovery, is implemented in a similar way.
dspin.h file content AN3980 9/18 doc id 022200 rev 1 4.2 dspin init structure definition to configure all l6470 registers a dedicated structure type has been defined: figure 5. l6470 registers structure type definition typically, a variable is created in the main program loop and filled with requested register parameters. then, the appropriate function call (dspin_registers_set(&dspin_regsstruct)) can program all registers as requested by the user. 4.3 register options / mask definition (enumerated types) as l6470 consists of 25 registers, and many of them include multiple parameter settings, the complete code to cover all the definitions is large. the following lists are just selected examples and the others can be found directly in the header file.
AN3980 dspin.h file content doc id 022200 rev 1 10/18 figure 6. step select parameters definition for ?step mode? register figure 7. configuration register mask definition 4.4 l6470 register addresses to allow access to l6470 registers, the following register address definition has been created.
dspin.h file content AN3980 11/18 doc id 022200 rev 1 figure 8. register addresses
AN3980 dspin.h file content doc id 022200 rev 1 12/18 4.5 l6470 command set definition dspin motion and other types of commands are coded with numeric (single byte) constants. for transparent code implementation, the following type definition has been created: figure 9. l6470 command set type definition 4.6 macros definition some of the l6470 commands use input parameters which are proportional to a real number. for this reason there is a need to recalculate (convert) the requested option parameter in real numeric format to the function parameter in integer format. to make it user friendly and allow usage of input parameters in real numeric format, macros for parameter conversion have been implemented. for example, the ?run? command supposes to get a speed parameter in unsigned fixed point 0.28 number format. in this case, the ?speed_steps_to_par(speed)? macro can be used to convert real speed (in steps per second) to the parameter of the ?run? command.
dspin.h file content AN3980 13/18 doc id 022200 rev 1 figure 10. list of defined macros
AN3980 dspin.c file content doc id 022200 rev 1 14/18 5 dspin.c file content dspin.c is the library source file. it contains all the l6470 commands and the implementation of other support functions. it starts with the dspin_peripherals_init function which configures all the required microcontroller peripherals (gpios, spi) and it is called at the beginning of the main program loop. the function considers signal assignments made in the dspin.h file. the dspin_regs_struct_reset function fills all the structure fields with default values. the dspin_registers_set function programs all parameters into l6470 internal registers. it uses pointer-to-structure as the input parameter, so the structure must be filled properly in advance of this function call. the dspin.c file contains all the dspin commands and the implementation of other support functions. the code is well commented, please refer directly to the file for more details.
main.c file content AN3980 15/18 doc id 022200 rev 1 6 main.c file content the main.c file starts with the system clock configuration in order to switch from internal rc oscillator to external crystal circuit. it sets sysclk frequency to 24 mhz. then, the above mentioned dspin_peripherals_init function is processed. the dspin_regs_struct_reset function is called to fill all dspin_regsstruct structure fields with default values. as a next step, the majority of the dspin_regsstruct fields are modified either directly or with the help of the macros already described (see section 4 ). l6470 internal registers are then programmed by the dspin_registers_set function. the rest of the main.c file code demonstrates how to use the library functions.
AN3980 demonstration boards images doc id 022200 rev 1 16/18 appendix a demonstration boards images figure 11. demonstration board steval-pcc009v2 figure 12. demonstration board stm32f100 value line discovery kit
demonstration boards images AN3980 17/18 doc id 022200 rev 1 figure 13. l6470 demonstration board (eval6470)
AN3980 references doc id 022200 rev 1 18/18 references 1. l6470 datasheet 2. an3103 application note 3. stm32f100rb datasheet 4. stm32f103rb datasheet 5. rm0041 - stm32f100 reference manual 6. rm0008 - stm32f103 reference manual 7. steval-pcc009v2 databrief 8. um0919 user manual revision history table 3. document revision history date revision changes 22-nov-2011 1 initial release.
AN3980 doc id 022200 rev 1 18/18 please read carefully: information in this document is provided solely in connection with st products. stmicroelectronics nv and its subsidiaries (?st ?) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described he rein at an y time, without notice. all st products are sold pursuant to st?s terms and conditions of sale. purchasers are solely responsible for the choice, selection and use of the st products and services described herein, and st as sumes no liability whatsoever relating to the choice, selection or use of the st products and services described herein. no license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. i f any part of this document refers to any third party products or services it shall not be deemed a license grant by st for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoev er of such third party products or services or any intellectual property contained therein. unless otherwise set forth in st?s terms and conditions of sale st disclaims any express or implied warranty with respect to the use and/or sale of st products including without limitation implied warranties of merchantability, fitness for a particular purpose (and their equivalents under the laws of any jurisdiction), or infringement of any patent, copyright or other intellectual property right. unless expressly approved in writing by two authorized st representatives, st products are not recommended, authorized or warranted for use in military, air craft, space, life saving, or life sustaining applications, nor in products or systems where failure or malfunction may result in personal injury, death, or severe property or environmental damage. st products which are not specified as "automotive grade" may only be used in automotive applications at user?s own risk. resale of st products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by st for the st product or service described herein and shall not create or extend in any manner whatsoev er, any liability of st. st and the st logo are trademarks or registered trademarks of st in various countries. information in this document supersedes and replaces all information previously supplied. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners. ? 2011 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia - belgium - brazil - canada - china - czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - philippines - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of AN3980

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X